//
//  PlayViewController.m
//  MMLOOK
//
//  Created by dllo on 15/10/10.
//  Copyright © 2015年 武俊娥. All rights reserved.
//

#import "PlayViewController.h"
#import "PlayDetailCollectionViewCell.h"
#import "Play.h"


@interface PlayViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>

@property(nonatomic, retain)UICollectionView *collect;

@end

@implementation PlayViewController

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        
    }
    return self;
    
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"视频";
    
    [self creatCollection];
    
}


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.translucent = NO;
    
    self.tabBarController.tabBar.hidden = YES;
    self.tabBarController.tabBar.translucent = NO;
    
      self.collect.contentOffset = CGPointMake(self.view.frame.size.width * self.count, 0);
}



-(void)creatCollection
{
    
     UICollectionViewFlowLayout *layout = [[[UICollectionViewFlowLayout alloc] init] autorelease];
    
     layout.itemSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height - 64 );
    
    layout.minimumInteritemSpacing = 0;
    
    layout.minimumLineSpacing= 0;
    
     layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
     self.collect = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width , self.view.frame.size.height - 64 ) collectionViewLayout:layout];
    
    self.collect.dataSource = self;
     self.collect.delegate = self;
    
     self.collect.pagingEnabled = YES;
     self.collect.backgroundColor = [UIColor whiteColor];
    
    [self.collect registerClass:[PlayDetailCollectionViewCell class] forCellWithReuseIdentifier:@"1111"];
    
    [self.view addSubview:self.collect];
    [_collect release];
    
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    return self.arr.count;
    
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    PlayDetailCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"1111" forIndexPath:indexPath];
    
    cell.play = [self.arr objectAtIndex:indexPath.item];
    
    cell.root = self;
    
    return cell;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
